﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:Chronos.Client.Win.Controls.Common.EventsTree">

<!-- ItemsControlVirtialisedStyle ================================================================================================== -->
    <Style x:Key="ItemsControlVirtialisedStyle" TargetType="ItemsControl">
        <Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ItemsControl">
                    <Border
                    BorderThickness="{TemplateBinding Border.BorderThickness}"
                    Padding="{TemplateBinding Control.Padding}"
                    BorderBrush="{TemplateBinding Border.BorderBrush}"
                    Background="{TemplateBinding Panel.Background}"
                    SnapsToDevicePixels="True">
                        <ScrollViewer Padding="{TemplateBinding Control.Padding}" Focusable="False">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
<!-- EventsTree ================================================================================================================= -->
    <Style x:Key="{x:Type controls:EventsTreeView}" TargetType="{x:Type controls:EventsTreeView}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:EventsTreeView}">
                    <!--<ScrollViewer x:Name="ScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">-->
                        <ItemsControl x:Name="ItemsControl" VirtualizingStackPanel.IsVirtualizing="True" Style="{StaticResource ItemsControlVirtialisedStyle}" />
                    <!--</ScrollViewer>-->
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
<!-- EventsTreeItem ================================================================================================================= -->
    <Style x:Key="{x:Type controls:EventsTreeItem}" TargetType="{x:Type controls:EventsTreeItem}">
        <Setter Property="FontSize" Value="13" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="LevelOffset" Value="10"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:EventsTreeItem}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Black" Opacity="0.001" />
                        <Border Grid.Row="0" x:Name="BackgroundBorder" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                        <Border BorderBrush="#F6F6F6" BorderThickness="0,0,0,1">
                            <StackPanel x:Name="HeaderPanel" Orientation="Horizontal" Cursor="Hand">
                                <Border x:Name="ChildrenIndicatorBorder" Width="3" Background="#000" />
                                <Border x:Name="PercentsColorIndicatorBorder" Width="40">
                                    <TextBlock x:Name="PercentTextBlock" HorizontalAlignment="Center" FontSize="11" />
                                </Border>
                                <TextBlock Text="[" Margin="0" FontWeight="SemiBold"/>
                                <TextBlock x:Name="TimeTextBlock" Margin="0" FontWeight="SemiBold" />
                                <TextBlock Text="," Margin="0" FontWeight="SemiBold"/>
                                <TextBlock x:Name="HitsTextBlock" Margin="0" FontWeight="SemiBold" />
                                <TextBlock Text="]" Margin="0" FontWeight="SemiBold"/>
                                <TextBlock x:Name="NameTextBlock" />
                            </StackPanel>
                        </Border>
                        <ItemsControl Grid.Row="1" x:Name="ChildrenItemsControl" Margin="15,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHovered" Value="true">
                            <Setter TargetName="BackgroundBorder" Property="Background" Value="#E6E6E6" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="BackgroundBorder" Property="Background" Value="#D6D6D6" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
